import { defineStore } from "pinia";
// import { useRouter } from 'vue-router';
// const router = useRouter()


// 真正存储数据的地方
export const useTabsStore = defineStore("tabs", {
    state: () => ({
        currentTab: '/admin/console',
        tabs: [{ id: '/admin/console', title: '控制台', closable: false }],
    }),

    actions: {
        addTab(tab: any) {
            if (this.tabs.findIndex(e => e.id === tab.path) === -1) {
                this.tabs.push({
                    id: tab.path,
                    title: tab.name
                })
            }
            this.currentTab = tab.path
            // router.push(tab.path)
        },

        resetTab() {
            this.currentTab = '/admin/console'
            this.tabs = [{ id: '/admin/console', title: '控制台', closable: false }]
        }
    },
});

export default useTabsStore;